/**用户接口 */
import request from "@/utils/request";
import {
    getRefreshToken
} from "@/utils/auth"
// 用户发布公钥接口
export function getPublicKey() {
    console.log("getpublic");
    return request({
        url: "/api/v1/key/public",
        method: "get",
    });
}
// 用户注册接口
export function UserRegister(data) {
    return request({
        url: "/api/v1/user/register",
        method: "post",
        data,
    });
}
// 用户登录接口
export function UserLogin(data) {
    return request({
        url: "/api/v1/user/login",
        method: "post",
        data,
    });
}
// 发送邮箱接口
export function SendVerificationCode(data) {
    console.log("email", data)
    return request({
        url: "/api/v1/email/send_verification_code",
        method: "post",
        data,
    });
}
// 获取RefreshToken
export function Refresh(refreshToken) {
    return request({
        headers: {
            Authorization: refreshToken
        },
        url: "/api/v1/token/refresh",
        method: "post",
    });
}
// 用户退出并删除AccessToken接口
export function LogOutAccessToken() {
    return request({
        url: "/api/v1/user/logout/access",
        method: "post",
    });
}
// 用户退出登录并删除RefreshToken
export function LogOutRefreshToken(refreshToken) {
    console.log(refreshToken);
    return request({
        headers: {
            Authorization: refreshToken
        },
        url: "/api/v1/user/logout/refresh",
        method: "post",
    });
}
// 获取当前用户信息
export function GetCurrentUserInfo() {
    return request({
        url: "/api/v1/user/current",
        method: "get",
    });
}
// 更新当前用户信息
export function updateUserInfo(data) {
    return request({
        url: "/api/v1/user/alter",
        method: "PUT",
        data
    })
}
// 修改密码接口
export function AlterPassword(data) {
    return request({
        url: "/api/v1/user/alter/password",
        method: "PUT",
        data
    })
}
// 根据id获取用户信息接口
export function getUserById(id) {
    return request({
        url: `/api/v1/user/getUserById/${id}`,
        method: "get",
    })
}
// 获取用户列表
export function getUserList(limit, page) {
    return request({
        url: `/api/v1/user/getUserList/${limit}/${page}`,
        method: "get",
    })
}
// 通过用户id获取评论列表
export function getCommentListByUserId(user_id, limit, page) {
    return request({
        url: `/api/v1/comment/getCommentByUserId/${user_id}/${limit}/${page}`,
        method: "get",
    })
}
// 通过用户id获取回复评论列表
export function getReplyCommentListByUserId(user_id, limit, page) {
    return request({
        url: `/api/v1/comment/getRepliesByUserId/${user_id}/${limit}/${page}`,
        method: "get",
    })
}
// 用户获取评论来源
export function getCommentOrigin(comment_id) {
    return request({
        url: `/api/v1/comment/getOriginResourceByCommentId/${comment_id}`,
        method: "get",
    })
}
// 用户获取回复评论来源
export function getReplyCommentOrigin(comment_id) {
    return request({
        url: `/api/v1/comment/getOriginResourceByCommentId/${comment_id}`,
        method: "get",
    })
}
// 删除回复评论
export function deleteReplyComment(data) {
    return request({
        url: `/api/v1/comment/deleteReply`,
        method: "delete",
        data,
    });
}
// 忘记密码接口
export function forgetPassword(data) {
    return request({
        url: `/api/v1/user/forget/password`,
        method: "put",
        data
    });
}